import { BasicColumn, FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
  // 列定义
  {
    title: '显示名称',
    dataIndex: 'displayName',
  },
  {
    title: '唯一编码',
    dataIndex: 'name',
    width: 200,
  },
  {
    title: '流程分类',
    dataIndex: 'type',
    width: 200,
    customRender: ({ text }) => {
      return render.renderDict(text, 'wf_process_type');
    },
  },
  {
    title: '是否已部署',
    dataIndex: 'isDeployed',
    width: 120,
    customRender: ({ text }) => {
      return render.renderDict(text, 'yes_no');
    },
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'displayName',
    label: '显示名称',
    component: 'JInput',
    colProps: { span: 6 },
  },
  {
    field: 'name',
    label: '唯一编码',
    component: 'JInput',
    colProps: { span: 6 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '主键',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    field: 'displayName',
    label: '显示名称',
    component: 'Input',
    //required: true,
    rules: [{ required: true, message: '请输入显示名称', trigger: 'blur' }],
  },
  {
    field: 'name',
    label: '唯一编码',
    component: 'Input',
    //required: true,
    rules: [{ required: true, message: '请输入唯一编码', trigger: 'blur' }],
  },
  {
    label: '流程分类',
    field: 'type',
    component: 'JDictSelectTag',
    rules: [{ required: true, message: '请选择流程分类', trigger: 'blur' }],
    componentProps: {
      dictCode: 'wf_process_type',
      dropdownStyle: {
        maxHeight: '100vh',
      },
      getPopupContainer: () => document.body,
    },
  },
  {
    field: 'icon',
    label: '图标',
    component: 'IconPicker',
    required: true,
    componentProps: {
      placeholder: '请选择图标',
    },
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    required: false,
    componentProps: {
      placeholder: '请输入备注',
    },
  },
];
